<template>
  <div class="app-container">
    <el-form :model="queryParams" ref="queryForm" size="small" :inline="true" v-show="showSearch" label-width="100px">
      <!--<el-form-item label="工厂名称" prop="factoryName">
        <el-input
          v-model="queryParams.factoryName"
          placeholder="请输入工厂名称"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>-->
      <!--<el-form-item label="公司代码" prop="factoryCode">
        <el-input
          v-model="queryParams.factoryCode"
          placeholder="请输入公司代码"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>-->
      <el-form-item label="入账日期" prop="billingDate">
        <el-date-picker clearable
          v-model="queryParams.billingDate"
          type="date"
          value-format="yyyy-MM-dd"
          placeholder="请选择入账日期">
        </el-date-picker>
      </el-form-item>
      <el-form-item label="伙伴名称" prop="partnerName">
        <el-input
          v-model="queryParams.partnerName"
          placeholder="请输入伙伴名称"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="伙伴代码" prop="partnerCode">
        <el-input
          v-model="queryParams.partnerCode"
          placeholder="请输入伙伴代码"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
     <!-- <el-form-item label="伙伴税号" prop="partnerEin">
        <el-input
          v-model="queryParams.partnerEin"
          placeholder="请输入伙伴税号"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="伙伴地址" prop="partnerAdress">
        <el-input
          v-model="queryParams.partnerAdress"
          placeholder="请输入伙伴地址"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="伙伴电话" prop="partnerPhone">
        <el-input
          v-model="queryParams.partnerPhone"
          placeholder="请输入伙伴电话"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="伙伴开户银行" prop="partnerBank">
        <el-input
          v-model="queryParams.partnerBank"
          placeholder="请输入伙伴开户银行"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="伙伴账号" prop="partnerAccount">
        <el-input
          v-model="queryParams.partnerAccount"
          placeholder="请输入伙伴账号"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="伙伴联系人" prop="partnerLinkman">
        <el-input
          v-model="queryParams.partnerLinkman"
          placeholder="请输入伙伴联系人"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="伙伴联系电话" prop="partnerLinkPhone">
        <el-input
          v-model="queryParams.partnerLinkPhone"
          placeholder="请输入伙伴联系电话"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="合同编号" prop="contractNo">
        <el-input
          v-model="queryParams.contractNo"
          placeholder="请输入合同编号"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="合同签订日期" prop="signDate">
        <el-date-picker clearable
          v-model="queryParams.signDate"
          type="date"
          value-format="yyyy-MM-dd"
          placeholder="请选择合同签订日期">
        </el-date-picker>
      </el-form-item>
      <el-form-item label="合同交货期" prop="deliveryDate">
        <el-date-picker clearable
          v-model="queryParams.deliveryDate"
          type="date"
          value-format="yyyy-MM-dd"
          placeholder="请选择合同交货期">
        </el-date-picker>
      </el-form-item>
      <el-form-item label="合同签订人" prop="signPerson">
        <el-input
          v-model="queryParams.signPerson"
          placeholder="请输入合同签订人"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>-->
      <el-form-item label="产品编号" prop="productNo">
        <el-input
          v-model="queryParams.productNo"
          placeholder="请输入产品编号"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="产品名称" prop="productName">
        <el-input
          v-model="queryParams.productName"
          placeholder="请输入产品名称"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="规格型号" prop="specifications">
        <el-input
          v-model="queryParams.specifications"
          placeholder="请输入规格型号"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
     <!-- <el-form-item label="单位" prop="unit">
        <el-input
          v-model="queryParams.unit"
          placeholder="请输入单位"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="合同金额" prop="contractAmount">
        <el-input
          v-model="queryParams.contractAmount"
          placeholder="请输入合同金额"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="合同单价" prop="contractPrice">
        <el-input
          v-model="queryParams.contractPrice"
          placeholder="请输入合同单价"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="合同数量" prop="contractNum">
        <el-input
          v-model="queryParams.contractNum"
          placeholder="请输入合同数量"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="发货日期" prop="sendPDate">
        <el-date-picker clearable
          v-model="queryParams.sendPDate"
          type="date"
          value-format="yyyy-MM-dd"
          placeholder="请选择发货日期">
        </el-date-picker>
      </el-form-item>
      <el-form-item label="发货数量" prop="sendPNum">
        <el-input
          v-model="queryParams.sendPNum"
          placeholder="请输入发货数量"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>-->
      <el-form-item label="开票日期" prop="kpDate">
        <el-date-picker clearable
          v-model="queryParams.kpDate"
          type="date"
          value-format="yyyy-MM-dd"
          placeholder="请选择开票日期">
        </el-date-picker>
      </el-form-item>
      <el-form-item label="开票人" prop="kpUser">
        <el-input
          v-model="queryParams.kpUser"
          placeholder="请输入开票人"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <!--<el-form-item label="取票人" prop="qpUser">
        <el-input
          v-model="queryParams.qpUser"
          placeholder="请输入取票人"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="票据流向" prop="paperFlow">
        <el-input
          v-model="queryParams.paperFlow"
          placeholder="请输入票据流向"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="税率" prop="taxRate">
        <el-input
          v-model="queryParams.taxRate"
          placeholder="请输入税率"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="发票号" prop="invoiceNo">
        <el-input
          v-model="queryParams.invoiceNo"
          placeholder="请输入发票号"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="开票数量" prop="kpNum">
        <el-input
          v-model="queryParams.kpNum"
          placeholder="请输入开票数量"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="开票单价" prop="kpPrice">
        <el-input
          v-model="queryParams.kpPrice"
          placeholder="请输入开票单价"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="开票金额" prop="kpMoney">
        <el-input
          v-model="queryParams.kpMoney"
          placeholder="请输入开票金额"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="发票金额" prop="invoiceMoney">
        <el-input
          v-model="queryParams.invoiceMoney"
          placeholder="请输入发票金额"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="记账金额" prop="keepAccountsMoney">
        <el-input
          v-model="queryParams.keepAccountsMoney"
          placeholder="请输入记账金额"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>-->
      <el-form-item label="收款日期" prop="receiptDate">
        <el-date-picker clearable
          v-model="queryParams.receiptDate"
          type="date"
          value-format="yyyy-MM-dd"
          placeholder="请选择收款日期">
        </el-date-picker>
      </el-form-item>
      <!--<el-form-item label="收款金额" prop="receiptMoney">
        <el-input
          v-model="queryParams.receiptMoney"
          placeholder="请输入收款金额"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="余额" prop="balance">
        <el-input
          v-model="queryParams.balance"
          placeholder="请输入余额"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>-->
      <el-form-item label="收付款人" prop="receivingUser">
        <el-input
          v-model="queryParams.receivingUser"
          placeholder="请输入收付款人"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="经办人" prop="agent">
        <el-input
          v-model="queryParams.agent"
          placeholder="请输入经办人"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
     <!-- <el-form-item label="提成比例" prop="commissionRatio">
        <el-input
          v-model="queryParams.commissionRatio"
          placeholder="请输入提成比例"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="提成金额" prop="ommissionMoney">
        <el-input
          v-model="queryParams.ommissionMoney"
          placeholder="请输入提成金额"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="是否呆账" prop="isDz">
        <el-input
          v-model="queryParams.isDz"
          placeholder="请输入是否呆账"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="材料成本单价" prop="materialPrice">
        <el-input
          v-model="queryParams.materialPrice"
          placeholder="请输入材料成本单价"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="材料成本金额" prop="materialMoney">
        <el-input
          v-model="queryParams.materialMoney"
          placeholder="请输入材料成本金额"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="人工成本单价" prop="artificialPrice">
        <el-input
          v-model="queryParams.artificialPrice"
          placeholder="请输入人工成本单价"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="人工成本金额" prop="artificialMoney">
        <el-input
          v-model="queryParams.artificialMoney"
          placeholder="请输入人工成本金额"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="加工成本单价" prop="processingPrice">
        <el-input
          v-model="queryParams.processingPrice"
          placeholder="请输入加工成本单价"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="加工成本金额" prop="processingMoney">
        <el-input
          v-model="queryParams.processingMoney"
          placeholder="请输入加工成本金额"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="成本合计单价" prop="cbTotalPrice">
        <el-input
          v-model="queryParams.cbTotalPrice"
          placeholder="请输入成本合计单价"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="成本合计金额" prop="cbTotalMoney">
        <el-input
          v-model="queryParams.cbTotalMoney"
          placeholder="请输入成本合计金额"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="折旧单价" prop="depreciationPrice">
        <el-input
          v-model="queryParams.depreciationPrice"
          placeholder="请输入折旧单价"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="折旧金额" prop="depreciationMoney">
        <el-input
          v-model="queryParams.depreciationMoney"
          placeholder="请输入折旧金额"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="管理费用金额" prop="managementFee">
        <el-input
          v-model="queryParams.managementFee"
          placeholder="请输入管理费用金额"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="运费金额" prop="freight">
        <el-input
          v-model="queryParams.freight"
          placeholder="请输入运费金额"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="财务费用金额" prop="financialCost">
        <el-input
          v-model="queryParams.financialCost"
          placeholder="请输入财务费用金额"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="其他费用金额" prop="otherCost">
        <el-input
          v-model="queryParams.otherCost"
          placeholder="请输入其他费用金额"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="毛利金额" prop="grossProfit">
        <el-input
          v-model="queryParams.grossProfit"
          placeholder="请输入毛利金额"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="利润金额" prop="profits">
        <el-input
          v-model="queryParams.profits"
          placeholder="请输入利润金额"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="毛利比例" prop="grossProfitRate">
        <el-input
          v-model="queryParams.grossProfitRate"
          placeholder="请输入毛利比例"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="利润比例" prop="profitsRate">
        <el-input
          v-model="queryParams.profitsRate"
          placeholder="请输入利润比例"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="合计金额" prop="totalAmount">
        <el-input
          v-model="queryParams.totalAmount"
          placeholder="请输入合计金额"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="累计金额" prop="aggregateAmount">
        <el-input
          v-model="queryParams.aggregateAmount"
          placeholder="请输入累计金额"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>-->
      <el-form-item>
        <el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
        <el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
      </el-form-item>
    </el-form>

    <el-row :gutter="10" class="mb8">
      <el-col :span="1.5">
        <el-button
          type="primary"
          plain
          icon="el-icon-plus"
          size="mini"
          @click="handleAdd"
          v-hasPermi="['business:account:add']"
        >新增</el-button>
      </el-col>
      <el-col :span="1.5">
        <el-button
          type="success"
          plain
          icon="el-icon-edit"
          size="mini"
          :disabled="single"
          @click="handleUpdate"
          v-hasPermi="['business:account:edit']"
        >修改</el-button>
      </el-col>
      <el-col :span="1.5">
        <el-button
          type="danger"
          plain
          icon="el-icon-delete"
          size="mini"
          :disabled="multiple"
          @click="handleDelete"
          v-hasPermi="['business:account:remove']"
        >删除</el-button>
      </el-col>
      <el-col :span="1.5">
        <el-button
          type="warning"
          plain
          icon="el-icon-download"
          size="mini"
          @click="handleExport"
          v-hasPermi="['business:account:export']"
        >导出</el-button>
      </el-col>
      <right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
    </el-row>

    <el-table v-loading="loading" :data="accountList" @selection-change="handleSelectionChange">
      <el-table-column type="selection" width="55" align="center" />
     <!-- <el-table-column label="主键" align="center" prop="id" />
      <el-table-column label="工厂名称" align="center" prop="factoryName" />-->
      <el-table-column label="公司代码" align="center" prop="factoryCode" />
      <el-table-column label="入账日期" align="center" prop="billingDate" width="120"/>
      <el-table-column label="入账类型" align="center" prop="billingType" />
      <el-table-column label="伙伴类型" align="center" prop="partnerType" />
      <el-table-column label="伙伴名称" align="center" prop="partnerName" />
      <el-table-column label="伙伴代码" align="center" prop="partnerCode" />
      <el-table-column label="伙伴税号" align="center" prop="partnerEin" />
      <el-table-column label="伙伴地址" align="center" prop="partnerAdress" />
      <el-table-column label="伙伴电话" align="center" prop="partnerPhone" />
      <el-table-column label="伙伴开户银行" align="center" prop="partnerBank" />
      <el-table-column label="伙伴账号" align="center" prop="partnerAccount" />
      <el-table-column label="伙伴联系人" align="center" prop="partnerLinkman" />
      <el-table-column label="伙伴联系电话" align="center" prop="partnerLinkPhone" />
      <el-table-column label="合同编号" align="center" prop="contractNo" />
      <el-table-column label="合同签订日期" align="center" prop="signDate" width="180">
        <template slot-scope="scope">
          <span>{{ parseTime(scope.row.signDate, '{y}-{m}-{d}') }}</span>
        </template>
      </el-table-column>
      <el-table-column label="合同交货期" align="center" prop="deliveryDate" width="180">
        <template slot-scope="scope">
          <span>{{ parseTime(scope.row.deliveryDate, '{y}-{m}-{d}') }}</span>
        </template>
      </el-table-column>
      <el-table-column label="合同签订人" align="center" prop="signPerson" />
      <el-table-column label="产品编号" align="center" prop="productNo" />
      <el-table-column label="产品名称" align="center" prop="productName" />
      <el-table-column label="规格型号" align="center" prop="specifications" />
      <el-table-column label="单位" align="center" prop="unit" />
      <el-table-column label="合同金额" align="center" prop="contractAmount" />
      <el-table-column label="合同单价" align="center" prop="contractPrice" />
      <el-table-column label="合同数量" align="center" prop="contractNum" />
      <el-table-column label="发货日期" align="center" prop="sendPDate" width="180">
        <template slot-scope="scope">
          <span>{{ parseTime(scope.row.sendPDate, '{y}-{m}-{d}') }}</span>
        </template>
      </el-table-column>
      <el-table-column label="发货数量" align="center" prop="sendPNum" />
      <el-table-column label="开票日期" align="center" prop="kpDate" width="180">
        <template slot-scope="scope">
          <span>{{ parseTime(scope.row.kpDate, '{y}-{m}-{d}') }}</span>
        </template>
      </el-table-column>
      <el-table-column label="票据类型" align="center" prop="paperType" />
      <el-table-column label="开票人" align="center" prop="kpUser" />
      <el-table-column label="取票人" align="center" prop="qpUser" />
      <el-table-column label="票据流向" align="center" prop="paperFlow" />
      <el-table-column label="税率" align="center" prop="taxRate" />
      <el-table-column label="发票号" align="center" prop="invoiceNo" />
      <el-table-column label="开票数量" align="center" prop="kpNum" />
      <el-table-column label="开票单价" align="center" prop="kpPrice" />
      <el-table-column label="开票金额" align="center" prop="kpMoney" />
      <el-table-column label="发票金额" align="center" prop="invoiceMoney" />
      <el-table-column label="记账金额" align="center" prop="keepAccountsMoney" />
      <el-table-column label="收款日期" align="center" prop="receiptDate" width="180">
        <template slot-scope="scope">
          <span>{{ parseTime(scope.row.receiptDate, '{y}-{m}-{d}') }}</span>
        </template>
      </el-table-column>
      <el-table-column label="收款金额" align="center" prop="receiptMoney" />
      <el-table-column label="余额" align="center" prop="balance" />
      <el-table-column label="收付款人" align="center" prop="receivingUser" />
      <el-table-column label="经办人" align="center" prop="agent" />
      <el-table-column label="提成比例" align="center" prop="commissionRatio" />
      <el-table-column label="提成金额" align="center" prop="ommissionMoney" />
      <el-table-column label="是否呆账" align="center" prop="isDz" />
      <el-table-column label="材料成本单价" align="center" prop="materialPrice" />
      <el-table-column label="材料成本金额" align="center" prop="materialMoney" />
      <el-table-column label="人工成本单价" align="center" prop="artificialPrice" />
      <el-table-column label="人工成本金额" align="center" prop="artificialMoney" />
      <el-table-column label="加工成本单价" align="center" prop="processingPrice" />
      <el-table-column label="加工成本金额" align="center" prop="processingMoney" />
      <el-table-column label="成本合计单价" align="center" prop="cbTotalPrice" />
      <el-table-column label="成本合计金额" align="center" prop="cbTotalMoney" />
      <el-table-column label="折旧单价" align="center" prop="depreciationPrice" />
      <el-table-column label="折旧金额" align="center" prop="depreciationMoney" />
      <el-table-column label="管理费用金额" align="center" prop="managementFee" />
      <el-table-column label="运费金额" align="center" prop="freight" />
      <el-table-column label="财务费用金额" align="center" prop="financialCost" />
      <el-table-column label="其他费用金额" align="center" prop="otherCost" />
      <el-table-column label="毛利金额" align="center" prop="grossProfit" />
      <el-table-column label="利润金额" align="center" prop="profits" />
      <el-table-column label="毛利比例" align="center" prop="grossProfitRate" />
      <el-table-column label="利润比例" align="center" prop="profitsRate" />
      <el-table-column label="合计金额" align="center" prop="totalAmount" />
      <el-table-column label="累计金额" align="center" prop="aggregateAmount" />
      <el-table-column label="备注" align="center" prop="remark" />
      <el-table-column label="操作" fixed="right" width="120" align="center" class-name="small-padding fixed-width">
        <template slot-scope="scope">
          <el-button
            size="mini"
            type="text"
            icon="el-icon-edit"
            @click="handleUpdate(scope.row)"
            v-hasPermi="['business:account:edit']"
          >修改</el-button>
          <el-button
            size="mini"
            type="text"
            icon="el-icon-delete"
            @click="handleDelete(scope.row)"
            v-hasPermi="['business:account:remove']"
          >删除</el-button>
        </template>
      </el-table-column>
    </el-table>

    <pagination
      v-show="total>0"
      :total="total"
      :page.sync="queryParams.pageNum"
      :limit.sync="queryParams.pageSize"
      @pagination="getList"
    />

    <!-- 添加或修改应收/付账款对话框 -->
    <el-dialog :close-on-click-modal="false" :title="title" :visible.sync="open" width="500px" append-to-body>
      <el-form ref="form" :model="form" :rules="rules" label-width="80px">
        <el-form-item label="工厂名称" prop="factoryName">
          <el-input v-model="form.factoryName" placeholder="请输入工厂名称" />
        </el-form-item>
        <el-form-item label="公司代码" prop="factoryCode">
          <el-input v-model="form.factoryCode" placeholder="请输入公司代码" />
        </el-form-item>
        <el-form-item label="入账日期" prop="billingDate">
          <el-date-picker clearable
            v-model="form.billingDate"
            type="date"
            value-format="yyyy-MM-dd"
            placeholder="请选择入账日期">
          </el-date-picker>
        </el-form-item>
        <el-form-item label="伙伴名称" prop="partnerName">
          <el-input v-model="form.partnerName" placeholder="请输入伙伴名称" />
        </el-form-item>
        <el-form-item label="伙伴代码" prop="partnerCode">
          <el-input v-model="form.partnerCode" placeholder="请输入伙伴代码" />
        </el-form-item>
        <el-form-item label="伙伴税号" prop="partnerEin">
          <el-input v-model="form.partnerEin" placeholder="请输入伙伴税号" />
        </el-form-item>
        <el-form-item label="伙伴地址" prop="partnerAdress">
          <el-input v-model="form.partnerAdress" placeholder="请输入伙伴地址" />
        </el-form-item>
        <el-form-item label="伙伴电话" prop="partnerPhone">
          <el-input v-model="form.partnerPhone" placeholder="请输入伙伴电话" />
        </el-form-item>
        <el-form-item label="伙伴开户银行" prop="partnerBank">
          <el-input v-model="form.partnerBank" placeholder="请输入伙伴开户银行" />
        </el-form-item>
        <el-form-item label="伙伴账号" prop="partnerAccount">
          <el-input v-model="form.partnerAccount" placeholder="请输入伙伴账号" />
        </el-form-item>
        <el-form-item label="伙伴联系人" prop="partnerLinkman">
          <el-input v-model="form.partnerLinkman" placeholder="请输入伙伴联系人" />
        </el-form-item>
        <el-form-item label="伙伴联系电话" prop="partnerLinkPhone">
          <el-input v-model="form.partnerLinkPhone" placeholder="请输入伙伴联系电话" />
        </el-form-item>
        <el-form-item label="合同编号" prop="contractNo">
          <el-input v-model="form.contractNo" placeholder="请输入合同编号" />
        </el-form-item>
        <el-form-item label="合同签订日期" prop="signDate">
          <el-date-picker clearable
            v-model="form.signDate"
            type="date"
            value-format="yyyy-MM-dd"
            placeholder="请选择合同签订日期">
          </el-date-picker>
        </el-form-item>
        <el-form-item label="合同交货期" prop="deliveryDate">
          <el-date-picker clearable
            v-model="form.deliveryDate"
            type="date"
            value-format="yyyy-MM-dd"
            placeholder="请选择合同交货期">
          </el-date-picker>
        </el-form-item>
        <el-form-item label="合同签订人" prop="signPerson">
          <el-input v-model="form.signPerson" placeholder="请输入合同签订人" />
        </el-form-item>
        <el-form-item label="产品编号" prop="productNo">
          <el-input v-model="form.productNo" placeholder="请输入产品编号" />
        </el-form-item>
        <el-form-item label="产品名称" prop="productName">
          <el-input v-model="form.productName" placeholder="请输入产品名称" />
        </el-form-item>
        <el-form-item label="规格型号" prop="specifications">
          <el-input v-model="form.specifications" placeholder="请输入规格型号" />
        </el-form-item>
        <el-form-item label="单位" prop="unit">
          <el-input v-model="form.unit" placeholder="请输入单位" />
        </el-form-item>
        <el-form-item label="合同金额" prop="contractAmount">
          <el-input v-model="form.contractAmount" placeholder="请输入合同金额" />
        </el-form-item>
        <el-form-item label="合同单价" prop="contractPrice">
          <el-input v-model="form.contractPrice" placeholder="请输入合同单价" />
        </el-form-item>
        <el-form-item label="合同数量" prop="contractNum">
          <el-input v-model="form.contractNum" placeholder="请输入合同数量" />
        </el-form-item>
        <el-form-item label="发货日期" prop="sendPDate">
          <el-date-picker clearable
            v-model="form.sendPDate"
            type="date"
            value-format="yyyy-MM-dd"
            placeholder="请选择发货日期">
          </el-date-picker>
        </el-form-item>
        <el-form-item label="发货数量" prop="sendPNum">
          <el-input v-model="form.sendPNum" placeholder="请输入发货数量" />
        </el-form-item>
        <el-form-item label="开票日期" prop="kpDate">
          <el-date-picker clearable
            v-model="form.kpDate"
            type="date"
            value-format="yyyy-MM-dd"
            placeholder="请选择开票日期">
          </el-date-picker>
        </el-form-item>
        <el-form-item label="开票人" prop="kpUser">
          <el-input v-model="form.kpUser" placeholder="请输入开票人" />
        </el-form-item>
        <el-form-item label="取票人" prop="qpUser">
          <el-input v-model="form.qpUser" placeholder="请输入取票人" />
        </el-form-item>
        <el-form-item label="票据流向" prop="paperFlow">
          <el-input v-model="form.paperFlow" placeholder="请输入票据流向" />
        </el-form-item>
        <el-form-item label="税率" prop="taxRate">
          <el-input v-model="form.taxRate" placeholder="请输入税率" />
        </el-form-item>
        <el-form-item label="发票号" prop="invoiceNo">
          <el-input v-model="form.invoiceNo" placeholder="请输入发票号" />
        </el-form-item>
        <el-form-item label="开票数量" prop="kpNum">
          <el-input v-model="form.kpNum" placeholder="请输入开票数量" />
        </el-form-item>
        <el-form-item label="开票单价" prop="kpPrice">
          <el-input v-model="form.kpPrice" placeholder="请输入开票单价" />
        </el-form-item>
        <el-form-item label="开票金额" prop="kpMoney">
          <el-input v-model="form.kpMoney" placeholder="请输入开票金额" />
        </el-form-item>
        <el-form-item label="发票金额" prop="invoiceMoney">
          <el-input v-model="form.invoiceMoney" placeholder="请输入发票金额" />
        </el-form-item>
        <el-form-item label="记账金额" prop="keepAccountsMoney">
          <el-input v-model="form.keepAccountsMoney" placeholder="请输入记账金额" />
        </el-form-item>
        <el-form-item label="收款日期" prop="receiptDate">
          <el-date-picker clearable
            v-model="form.receiptDate"
            type="date"
            value-format="yyyy-MM-dd"
            placeholder="请选择收款日期">
          </el-date-picker>
        </el-form-item>
        <el-form-item label="收款金额" prop="receiptMoney">
          <el-input v-model="form.receiptMoney" placeholder="请输入收款金额" />
        </el-form-item>
        <el-form-item label="余额" prop="balance">
          <el-input v-model="form.balance" placeholder="请输入余额" />
        </el-form-item>
        <el-form-item label="收付款人" prop="receivingUser">
          <el-input v-model="form.receivingUser" placeholder="请输入收付款人" />
        </el-form-item>
        <el-form-item label="经办人" prop="agent">
          <el-input v-model="form.agent" placeholder="请输入经办人" />
        </el-form-item>
        <el-form-item label="提成比例" prop="commissionRatio">
          <el-input v-model="form.commissionRatio" placeholder="请输入提成比例" />
        </el-form-item>
        <el-form-item label="提成金额" prop="ommissionMoney">
          <el-input v-model="form.ommissionMoney" placeholder="请输入提成金额" />
        </el-form-item>
        <el-form-item label="是否呆账" prop="isDz">
          <el-input v-model="form.isDz" placeholder="请输入是否呆账" />
        </el-form-item>
        <el-form-item label="材料成本单价" prop="materialPrice">
          <el-input v-model="form.materialPrice" placeholder="请输入材料成本单价" />
        </el-form-item>
        <el-form-item label="材料成本金额" prop="materialMoney">
          <el-input v-model="form.materialMoney" placeholder="请输入材料成本金额" />
        </el-form-item>
        <el-form-item label="人工成本单价" prop="artificialPrice">
          <el-input v-model="form.artificialPrice" placeholder="请输入人工成本单价" />
        </el-form-item>
        <el-form-item label="人工成本金额" prop="artificialMoney">
          <el-input v-model="form.artificialMoney" placeholder="请输入人工成本金额" />
        </el-form-item>
        <el-form-item label="加工成本单价" prop="processingPrice">
          <el-input v-model="form.processingPrice" placeholder="请输入加工成本单价" />
        </el-form-item>
        <el-form-item label="加工成本金额" prop="processingMoney">
          <el-input v-model="form.processingMoney" placeholder="请输入加工成本金额" />
        </el-form-item>
        <el-form-item label="成本合计单价" prop="cbTotalPrice">
          <el-input v-model="form.cbTotalPrice" placeholder="请输入成本合计单价" />
        </el-form-item>
        <el-form-item label="成本合计金额" prop="cbTotalMoney">
          <el-input v-model="form.cbTotalMoney" placeholder="请输入成本合计金额" />
        </el-form-item>
        <el-form-item label="折旧单价" prop="depreciationPrice">
          <el-input v-model="form.depreciationPrice" placeholder="请输入折旧单价" />
        </el-form-item>
        <el-form-item label="折旧金额" prop="depreciationMoney">
          <el-input v-model="form.depreciationMoney" placeholder="请输入折旧金额" />
        </el-form-item>
        <el-form-item label="管理费用金额" prop="managementFee">
          <el-input v-model="form.managementFee" placeholder="请输入管理费用金额" />
        </el-form-item>
        <el-form-item label="运费金额" prop="freight">
          <el-input v-model="form.freight" placeholder="请输入运费金额" />
        </el-form-item>
        <el-form-item label="财务费用金额" prop="financialCost">
          <el-input v-model="form.financialCost" placeholder="请输入财务费用金额" />
        </el-form-item>
        <el-form-item label="其他费用金额" prop="otherCost">
          <el-input v-model="form.otherCost" placeholder="请输入其他费用金额" />
        </el-form-item>
        <el-form-item label="毛利金额" prop="grossProfit">
          <el-input v-model="form.grossProfit" placeholder="请输入毛利金额" />
        </el-form-item>
        <el-form-item label="利润金额" prop="profits">
          <el-input v-model="form.profits" placeholder="请输入利润金额" />
        </el-form-item>
        <el-form-item label="毛利比例" prop="grossProfitRate">
          <el-input v-model="form.grossProfitRate" placeholder="请输入毛利比例" />
        </el-form-item>
        <el-form-item label="利润比例" prop="profitsRate">
          <el-input v-model="form.profitsRate" placeholder="请输入利润比例" />
        </el-form-item>
        <el-form-item label="合计金额" prop="totalAmount">
          <el-input v-model="form.totalAmount" placeholder="请输入合计金额" />
        </el-form-item>
        <el-form-item label="累计金额" prop="aggregateAmount">
          <el-input v-model="form.aggregateAmount" placeholder="请输入累计金额" />
        </el-form-item>
        <el-form-item label="备注" prop="remark">
          <el-input v-model="form.remark" placeholder="请输入备注" />
        </el-form-item>
      </el-form>
      <div slot="footer" class="dialog-footer">
        <el-button type="primary" @click="submitForm">确 定</el-button>
        <el-button @click="cancel">取 消</el-button>
      </div>
    </el-dialog>
  </div>
</template>

<script>
import { listAccount, getAccount, delAccount, addAccount, updateAccount } from "@/api/business/account";

export default {
  name: "AccountPayable",
  data() {
    return {
      // 遮罩层
      loading: true,
      // 选中数组
      ids: [],
      // 非单个禁用
      single: true,
      // 非多个禁用
      multiple: true,
      // 显示搜索条件
      showSearch: true,
      // 总条数
      total: 0,
      // 应收/付账款表格数据
      accountList: [],
      // 弹出层标题
      title: "",
      // 是否显示弹出层
      open: false,
      // 查询参数
      queryParams: {
        pageNum: 1,
        pageSize: 10,
        factoryName: null,
        factoryCode: null,
        billingDate: null,
        billingType: "2",
        partnerType: null,
        partnerName: null,
        partnerCode: null,
        partnerEin: null,
        partnerAdress: null,
        partnerPhone: null,
        partnerBank: null,
        partnerAccount: null,
        partnerLinkman: null,
        partnerLinkPhone: null,
        contractNo: null,
        signDate: null,
        deliveryDate: null,
        signPerson: null,
        productNo: null,
        productName: null,
        specifications: null,
        unit: null,
        contractAmount: null,
        contractPrice: null,
        contractNum: null,
        sendPDate: null,
        sendPNum: null,
        kpDate: null,
        paperType: null,
        kpUser: null,
        qpUser: null,
        paperFlow: null,
        taxRate: null,
        invoiceNo: null,
        kpNum: null,
        kpPrice: null,
        kpMoney: null,
        invoiceMoney: null,
        keepAccountsMoney: null,
        receiptDate: null,
        receiptMoney: null,
        balance: null,
        receivingUser: null,
        agent: null,
        commissionRatio: null,
        ommissionMoney: null,
        isDz: null,
        materialPrice: null,
        materialMoney: null,
        artificialPrice: null,
        artificialMoney: null,
        processingPrice: null,
        processingMoney: null,
        cbTotalPrice: null,
        cbTotalMoney: null,
        depreciationPrice: null,
        depreciationMoney: null,
        managementFee: null,
        freight: null,
        financialCost: null,
        otherCost: null,
        grossProfit: null,
        profits: null,
        grossProfitRate: null,
        profitsRate: null,
        totalAmount: null,
        aggregateAmount: null,
      },
      // 表单参数
      form: {},
      // 表单校验
      rules: {
      }
    };
  },
  created() {
    this.getList();
  },
  methods: {
    /** 查询应收/付账款列表 */
    getList() {
      this.loading = true;
      listAccount(this.queryParams).then(response => {
        this.accountList = response.rows;
        this.total = response.total;
        this.loading = false;
      });
    },
    // 取消按钮
    cancel() {
      this.open = false;
      this.reset();
    },
    // 表单重置
    reset() {
      this.form = {
        id: null,
        factoryName: null,
        factoryCode: null,
        billingDate: null,
        billingType: null,
        partnerType: null,
        partnerName: null,
        partnerCode: null,
        partnerEin: null,
        partnerAdress: null,
        partnerPhone: null,
        partnerBank: null,
        partnerAccount: null,
        partnerLinkman: null,
        partnerLinkPhone: null,
        contractNo: null,
        signDate: null,
        deliveryDate: null,
        signPerson: null,
        productNo: null,
        productName: null,
        specifications: null,
        unit: null,
        contractAmount: null,
        contractPrice: null,
        contractNum: null,
        sendPDate: null,
        sendPNum: null,
        kpDate: null,
        paperType: null,
        kpUser: null,
        qpUser: null,
        paperFlow: null,
        taxRate: null,
        invoiceNo: null,
        kpNum: null,
        kpPrice: null,
        kpMoney: null,
        invoiceMoney: null,
        keepAccountsMoney: null,
        receiptDate: null,
        receiptMoney: null,
        balance: null,
        receivingUser: null,
        agent: null,
        commissionRatio: null,
        ommissionMoney: null,
        isDz: null,
        materialPrice: null,
        materialMoney: null,
        artificialPrice: null,
        artificialMoney: null,
        processingPrice: null,
        processingMoney: null,
        cbTotalPrice: null,
        cbTotalMoney: null,
        depreciationPrice: null,
        depreciationMoney: null,
        managementFee: null,
        freight: null,
        financialCost: null,
        otherCost: null,
        grossProfit: null,
        profits: null,
        grossProfitRate: null,
        profitsRate: null,
        totalAmount: null,
        aggregateAmount: null,
        remark: null
      };
      this.resetForm("form");
    },
    /** 搜索按钮操作 */
    handleQuery() {
      this.queryParams.pageNum = 1;
      this.getList();
    },
    /** 重置按钮操作 */
    resetQuery() {
      this.resetForm("queryForm");
      this.handleQuery();
    },
    // 多选框选中数据
    handleSelectionChange(selection) {
      this.ids = selection.map(item => item.id)
      this.single = selection.length!==1
      this.multiple = !selection.length
    },
    /** 新增按钮操作 */
    handleAdd() {
      this.reset();
      this.open = true;
      this.title = "添加应收账款";
    },
    /** 修改按钮操作 */
    handleUpdate(row) {
      this.reset();
      const id = row.id || this.ids
      getAccount(id).then(response => {
        this.form = response.data;
        this.open = true;
        this.title = "修改应收账款";
      });
    },
    /** 提交按钮 */
    submitForm() {
      this.$refs["form"].validate(valid => {
        if (valid) {
          if (this.form.id != null) {
            updateAccount(this.form).then(response => {
              this.$modal.msgSuccess("修改成功");
              this.open = false;
              this.getList();
            });
          } else {
            addAccount(this.form).then(response => {
              this.$modal.msgSuccess("新增成功");
              this.open = false;
              this.getList();
            });
          }
        }
      });
    },
    /** 删除按钮操作 */
    handleDelete(row) {
      const ids = row.id || this.ids;
      this.$modal.confirm('是否确认删除应收款编号为"' + ids + '"的数据项？').then(function() {
        return delAccount(ids);
      }).then(() => {
        this.getList();
        this.$modal.msgSuccess("删除成功");
      }).catch(() => {});
    },
    /** 导出按钮操作 */
    handleExport() {
      this.download('business/account/export', {
        ...this.queryParams
      }, `account_${new Date().getTime()}.xlsx`)
    }
  }
};
</script>
